import {
  isPC,
  reLogin
} from 'tools/utils'

const login = () =>
  import ('page/login');

const RoomList = () =>
  import ('page/RoomList');

const VideoRoom = () =>
  import ('page/videoRoom');

const MyInfo = () =>
  import ('page/MyInfo');

const LiveConfig = () =>
  import ('page/LiveConfig');

export const routes = [{
  path: '/',
  name: 'RoomList',
  component: RoomList
}, {
  path: '/login',
  name: 'login',
  component: login
}, {
  path: '/phone',
  name: 'RoomList',
  component: RoomList
}, {
  path: '/pc',
  name: 'RoomList',
  component: RoomList
}, {
  path: '/myInfo',
  name: 'MyInfo',
  component: MyInfo
}, {
  path: '/liveConfig',
  name: 'liveConfig',
  component: LiveConfig
}, {
  path: '/videoRoom',
  name: 'VideoRoom',
  component: VideoRoom
},
  //配置404页面
  // {
  //     path: '*',
  //     component: index
  // }
]


export function beforeEach(to, from, next) {
  if (to.path !== '/login') {
    let isLogin = JSON.parse(sessionStorage.getItem('isLogin'))
    if (!isLogin) {
      // 重新触发登录
      next({
        path: 'login'
      })
    }
  }
  if (to.path == '/') {
    // if (isPC()) {
    //   next({
    //     path: 'pc'
    //   })
    // } else {
      next({
        path: '/phone'
      })
    // }
  }

  next()
}
